/*
 * @Author: sunkai@xinxinapp.cn
 * @Date: 2021-04-01 16:16:19
 * @LastEditTime: 2021-04-01 16:25:26
 * @LastEditors: sunkai@xinxinapp.cn
 * @Description: 
 * @FilePath: /my-app/src/Item.js
 */
import React from 'react';
import './appleItem.scss';
import {observer} from 'mobx-react';

@observer
class AppleItem extends React.Component {

  render() {
    let { apple, eatApple } = this.props;
    return (
      <div className="appleItem">
        <div className="apple"><img src={require('../images/apple.png')} alt=""/></div>
        <div className="info">
          <div className="name">红苹果 - { apple.id }号</div>
          <div className="weight">{ apple.weight }克</div>
        </div>
        <div className="btn-div">
          <button onClick={()=>eatApple(apple.id)}> 吃掉 </button>
        </div>
      </div>
    );
  }
}

AppleItem.propTypes = {
  eatApple: React.PropTypes.func.isRequired,  
  apple: React.PropTypes.object.isRequired    
}
export default AppleItem;